﻿#include "uiparameterize.h"
#include "ui_uiparameterize.h"

#include <QIntValidator>
#include <QHostInfo>
#include <QMessageBox>
#include "protocol/protocol.h"
#include "protocol/protocol_struct.h"
#include "app_struct.h"
#include "app_global.h"

uiParameterize::uiParameterize(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::uiParameterize)
{
    ui->setupUi(this);
    //实例化窗口
     ui_acquisitionmodel = new acquisitionModel(this);       //采集模型ui
     ui_forwardModel = new forwardModel(this);               //转发模型ui
     ui_systemcfg = new Qsystem_cfg(this);                   //系统配置ui
     ui_cfgchannel = new uiCfgChannel(this);                 //通道配置ui

    ui->stackedWidget->addWidget(ui_acquisitionmodel);       //增加界面到控件中
    ui->stackedWidget->addWidget(ui_forwardModel);           //增加界面到控件中
    ui->stackedWidget->addWidget(ui_systemcfg);              //增加界面到控件中
    ui->stackedWidget->addWidget(ui_cfgchannel);             //增加界面到控件中

    qDebug() << "页面索引总数: " << ui->stackedWidget->count();

    SetCurrentWidget(0);            //通道配置ui
}

uiParameterize::~uiParameterize()
{
    delete ui;
}

/* 设置界面切换 */
void uiParameterize::SetCurrentWidget(uint8_t index){

    switch (index) {
        case 0  :
           ui->stackedWidget->setCurrentWidget(ui_cfgchannel);          //通道配置ui
           break; /* 可选的 */
        case 1  :
           ui->stackedWidget->setCurrentWidget(ui_acquisitionmodel);    //采集模型ui
           break; /* 可选的 */
        case 2 :
           ui->stackedWidget->setCurrentWidget(ui_forwardModel);        //转发模型ui
           break; /* 可选的 */
        case 3 :
           ui->stackedWidget->setCurrentWidget(ui_systemcfg);           //系统配置ui
           break; /* 可选的 */

        /* 您可以有任意数量的 case 语句 */
        default : /* 可选的 */
           ui->stackedWidget->setCurrentWidget(ui_cfgchannel);          //通道配置ui
    }
     qDebug() << "页面索引总数: " << ui->stackedWidget->count();
}

//通道配置按钮
void uiParameterize::on_pushButtontongdaopeizhi_clicked()
{
    SetCurrentWidget(0);
}

//采集模型按钮
void uiParameterize::on_pushButtoncaijimoxing_clicked()
{
    SetCurrentWidget(1);
}

//转发模型按钮
void uiParameterize::on_pushButtonzhuanfamoxing_clicked()
{
    SetCurrentWidget(2);
}

//系统配置按钮
void uiParameterize::on_pushButtonxitongpeizhi_clicked()
{
    SetCurrentWidget(3);
}

